package com.wgo.precise.client.ui.view.projecttree;

import static com.wgo.precise.client.ui.controller.PrecisePluginImage.IMG_CREATE_REQUIREMENT;

import com.wgo.precise.client.ui.controller.RequirementPlugin;
import com.wgo.precise.client.ui.model.CategoryWrapper;
import com.wgo.precise.client.ui.model.RequirementWrapper;
import com.wgo.precise.common.VO.Requirement;

/**
 * 
 * @author Petter L. H. Eide
 * @version $Id: CreateRequirementAction.java,v 1.2 2006-01-30 21:52:33 petterei Exp $
 */
public class CreateRequirementAction extends CreateAction<RequirementWrapper, CategoryWrapper> {

    public CreateRequirementAction(CategoryWrapper item) {
        super(createText(Requirement.class.getSimpleName()), item, IMG_CREATE_REQUIREMENT.getImageDescriptor());
    }

    /**
     * @see com.wgo.precise.client.ui.view.projecttree.CrudAction#run()
     */
    @Override
    public void run() {
        Requirement domainProject = RequirementPlugin.getInstance().getSession().getDomainSession().createPersistent(Requirement.class);
        RequirementWrapper item = RequirementPlugin.getInstance().getSession().getWrapperFactory().getWrapper(domainProject);
        item.setParent(getItem());
        setNewItem(item);
        super.run();
    }
    
}
